package com.yhgarden.bbs.controller.system;


import com.yhgarden.bbs.entity.system.EntityProperty;
import com.yhgarden.bbs.model.response.BaseResponse;
import com.yhgarden.bbs.service.api.system.EntityPropertyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping(value = {"/system/entityProperty","*/system/entityProperty"})
public class EntityPropertyController {

    @Autowired
    private EntityPropertyService entityPropertyService;

    /**
     * 创建或者更新字段
     */
    @RequestMapping(value = "/createOrUpdate", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse createOrUpdate(@RequestBody EntityProperty entityProperty) {
        BaseResponse res = entityPropertyService.createOrUpdate(entityProperty);
        return res;
    }

    @RequestMapping(value = "/getById/{propertyId}", method = RequestMethod.GET)
    @ResponseBody
    public BaseResponse getById(@PathVariable("propertyId") String propertyId) {
        BaseResponse res = entityPropertyService.getById(propertyId);
        return res;
    }

    @RequestMapping(value = "/getByIdMoreDetail/{propertyId}", method = RequestMethod.GET)
    @ResponseBody
    public BaseResponse getByIdMoreDetail(@PathVariable("propertyId") String propertyId) {
        BaseResponse res = entityPropertyService.getByIdMoreDetail(propertyId);
        return res;
    }

    @RequestMapping(value = "/query", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse query(@RequestBody EntityProperty entityProperty) {
        BaseResponse res = entityPropertyService.query(entityProperty);
        return res;
    }

    @RequestMapping(value = "/queryMoreDetail", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse queryMoreDetail(@RequestBody EntityProperty entityProperty) {
        BaseResponse res = entityPropertyService.queryMoreDetail(entityProperty);
        return res;
    }

    @RequestMapping(value = "/queryForList", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse queryForList(@RequestBody EntityProperty entityProperty) {
        BaseResponse res = entityPropertyService.queryForList(entityProperty);
        return res;
    }

    @RequestMapping(value = "/delete/{propertyId}", method = RequestMethod.POST)
    @ResponseBody
    public BaseResponse delete(@PathVariable("propertyId") String propertyId) {
        BaseResponse res = entityPropertyService.delete(propertyId);
        return res;
    }

    @RequestMapping(value = "/batchDelete/{entityId}", method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    @ResponseBody
    public BaseResponse batchDelete(@PathVariable("entityId") String entityId, @RequestBody List<String> ids) {
        BaseResponse res = entityPropertyService.batchDelete(entityId, ids);
        return res;
    }

}
